
#include "sentence.h"

int compareSegmentFragment(const SegmentFragment * lsf, const SegmentFragment * rsf)
{
	wchar_t *lb = lsf->begin;
	wchar_t *rb = rsf->begin;
	for(; lb != lsf->end+1 && rb != rsf->end+1 && *lb==*rb; lb++,rb++);

	if( lb == lsf->end +1 && rb == rsf->end +1)
		return 0;
	else if( lb == lsf->end +1)
		return -1;
	else if( rb == rsf->end +1)
		return 1;
	else
		return *lb-*rb;
}
bool operator==(const SegmentFragment& lsf, const SegmentFragment& rsf)
{
	if(compareSegmentFragment(&lsf,&rsf) == 0)
		return true;
	else 
		return false;

}

bool operator!=(const SegmentFragment& lsf, const SegmentFragment& rsf)
{
	if(compareSegmentFragment(&lsf,&rsf) == 0)
		return false;
	else 
		return true;
}

bool operator>(const SegmentFragment& lsf, const SegmentFragment& rsf)
{
	if(compareSegmentFragment(&lsf,&rsf) > 0)
		return true;
	else 
		return false;
}

bool operator<(const SegmentFragment& lsf, const SegmentFragment& rsf)
{
	if(compareSegmentFragment(&lsf,&rsf) < 0)
		return true;
	else 
		return false;
}